package com.masterclient.app.modules.purchase.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.masterclient.app.R;

/**
 * @auther hjian
 * @date 2020/10/10.
 */
public class GuideSaleOrderDialog extends Dialog {

    private int marginTop;
    private Context context;
    private int number = 0;
    private ImageView iv;
    private LinearLayout root;

    public GuideSaleOrderDialog(Context context, int marginTop) {
        super(context, R.style.MyDialog);
        this.marginTop = marginTop;
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_guide_sale_order);
        setCanceledOnTouchOutside(true);
        iv = findViewById(R.id.dialog_guide_sale_order_iv);
        root = findViewById(R.id.dialog_guide_sale_order_root);
        root.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (number == 0){
                    root.setPadding(0,marginTop,0,0);
                    iv.setImageResource(R.mipmap.sale_order_guide_two);
                    ++ number;
                }else {
                    dismiss();
                }
            }
        });
    }


    @Override
    protected void onStart() {
        super.onStart();
        Window window = getWindow();
        WindowManager.LayoutParams windowParams = window.getAttributes();
        window.setGravity(Gravity.TOP);
        windowParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        windowParams.height = WindowManager.LayoutParams.MATCH_PARENT;
        window.setBackgroundDrawableResource(android.R.color.transparent);
        window.setAttributes(windowParams);
    }
}
